<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <p id="text" class="text" data-type="title" align="center"></p>
    <script>
        var p=document.getElementById('text');
        console.log(p.getAttribute('class'));

        //设置属性功能
        p.setAttribute('data-color','red');
        //删除p标签的align属性
        p.removeAttribute('align');

    </script>

</body>
</html>